//
//  GoOutAcePackDetailCell.m
//  ArtOfLiving
//
//  Created by 刘虎 on 16/5/3.
//  Copyright © 2016年 刘虎. All rights reserved.
//

#import "GoOutAcePackDetailCell.h"
#import "GoOutAcePackTopicModel.h"

@interface GoOutAcePackDetailCell ()

@property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *locationLabel;
@property (weak, nonatomic) IBOutlet UILabel *downCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *updataTimeLabel;

@end


@implementation GoOutAcePackDetailCell


- (void)setCellWithModel:(id)model {
    
    
    GoOutAcePackTopicModel *topicModel = model;
    SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageLowPriority;
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/260_390.jpg?cover_updatetime=%@", topicModel.cover, topicModel.cover_updatetime]] placeholderImage:[UIImage imageNamed:@"travelPlaceholder.png"] options:options];
    self.locationLabel.text = [NSString stringWithFormat:@"%@/%@", topicModel.category_title, topicModel.country_name_cn];
    self.downCountLabel.text = [NSString stringWithFormat:@"%@次下载", topicModel.download];
    NSDate *date = [self dateWithString:topicModel.update_time];
    NSString *str = [self stringWithDate:date];
    self.updataTimeLabel.text = [NSString stringWithFormat:@"最新更新%@", str];
    self.titleLabel.text = topicModel.cnname;
    
}


#pragma mark  - 时间字符串相互转换
- (NSString *)stringWithDate:(NSDate *)date {
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YY.MM.dd"];
    NSString *timeStr = [dateFormatter stringFromDate:date];
    return timeStr;
}

- (NSDate *)dateWithString:(NSString *)string {
    
    NSInteger timeInterval = string.integerValue;
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:timeInterval];
    return date;
}

@end
